//
//  CharacterViewController.h
//  PacIsBack
//
//  Created by Jérémy Brault on 21/01/10.
//  Copyright 2010 None. All rights reserved.
//

#import <UIKit/UIKit.h>
@protocol CharacterProtocol;
@class CharacterBattleAnimationController;
@class LifeBarViewController;


@interface CharacterViewController : UIViewController {
	
	id<CharacterProtocol> character;
	CharacterBattleAnimationController* animationController;
	NSArray* spritesMoveLeft;
	NSArray* spritesMoveRight;
	NSArray* spritesSelected;
	NSArray* spritesStand;
	NSArray* spritesAttack;
	NSArray* currentAnim;
	NSTimer* animationTimer;
	NSInteger indexOfCurrentImage;
	CGPoint originalPosition;
	BOOL spriteAnimationActive;
	BOOL spriteAnimationMustLoop;
	BOOL characterPerformingAnimation;
	SEL selectorSpriteAnimationEnded;
	id targetForSelectorSpriteAnimationEnded;
	UIImageView* currentFrameView;
	LifeBarViewController* lifeBarsController;
	UITextView* currentDamagesView;
	NSInteger nbActions;
}

@property(nonatomic,retain) id<CharacterProtocol> character;
@property(nonatomic,retain) CharacterBattleAnimationController* animationController;
@property(nonatomic,retain) NSArray* spritesMoveLeft;
@property(nonatomic,retain) NSArray* spritesMoveRight;
@property(nonatomic,retain) NSArray* spritesSelected;
@property(nonatomic,retain) NSArray* spritesStand;
@property(nonatomic,retain) NSArray* spritesAttack;
@property(nonatomic,retain) NSArray* currentAnim;
@property(nonatomic,retain) NSTimer* animationTimer;
@property(nonatomic,assign) CGPoint originalPosition;
@property(nonatomic,assign) NSInteger indexOfCurrentImage;
@property(nonatomic,assign) BOOL spriteAnimationActive;
@property(nonatomic,assign) BOOL spriteAnimationMustLoop;
@property(nonatomic,assign) BOOL characterPerformingAnimation;
@property(nonatomic,assign) SEL selectorSpriteAnimationEnded;
@property(nonatomic,retain) id targetForSelectorSpriteAnimationEnded;
@property(nonatomic,retain) UIImageView* currentFrameView;
@property(nonatomic,retain) LifeBarViewController* lifeBarsController;
@property(nonatomic,retain) UITextView* currentDamagesView;
@property(nonatomic,assign) NSInteger nbActions;

-(id) initCharacterControllerForModel:(id<CharacterProtocol>) model;
-(void) nextFrame;
-(void) moveTo:(CGPoint) destination;
-(void) moveCharacter:(CGPoint) destination :(SEL) endAnimationSelector;
-(void) animateDeath;
-(void) animateSelected;
-(void) animateStand;
-(void) animateMoveLeft;
-(void) animateMoveRight;
-(void) animateAttackOnceWithSelectorSpriteAnimationEnded:(SEL) selector;
-(void) animateAttackOnceWithSelectorSpriteAnimationEnded:(SEL) selector onTarget:(id)selectorTarget;
-(void) executeAttackWithNSValue:(NSValue*) targetLocation;
-(void) executeAttack:(CGPoint) targetLocation;
-(void) changeAttackTargetPosition:(CGPoint) newTargetPosition;
-(void) executeAttackPhase2;
-(void) executeAttackPhase3;
-(void) fireAnimationTimer;
-(void) stopAnimationTimer;
-(void) resetTimerWithInterval:(NSTimeInterval) interval;
-(void) trySelecting;
-(void) select;
-(void) unselect;
-(void) showDamages:(NSInteger) damages;
-(void) removeDamageView;
-(void) changeHealth:(NSInteger) newHealth;
-(void) changeMana:(NSInteger) newMana;
-(void) setActionEnded;

@end
